winsafe\dxgi\com_interfaces/
idxgiadapter.rs

1#![allow(non_camel_case_types, non_snake_case)]
2
3use crate::decl::*;
4use crate::dxgi::{iterators::*, vts::*};
5use crate::kernel::privs::*;
6use crate::ole::privs::*;
7use crate::prelude::*;
8
9com_interface! { IDXGIAdapter: "2411e7e1-12ac-4ccf-bd14-9798e8534dc0";
10	/// [`IDXGIAdapter`](https://learn.microsoft.com/en-us/windows/win32/api/dxgi/nn-dxgi-idxgiadapter)
11	/// COM interface.
12	///
13	/// Automatically calls
14	/// [`Release`](https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-release)
15	/// when the object goes out of scope.
16}
17
18impl dxgi_IDXGIObject for IDXGIAdapter {}
19impl dxgi_IDXGIAdapter for IDXGIAdapter {}
20
21/// This trait is enabled with the `dxgi` feature, and provides methods for
22/// [`IDXGIAdapter`](crate::IDXGIAdapter).
23///
24/// Prefer importing this trait through the prelude:
25///
26/// ```no_run
27/// use winsafe::prelude::*;
28/// ```
29pub trait dxgi_IDXGIAdapter: dxgi_IDXGIObject {
30	/// [`IDXGIAdapter::CheckInterfaceSupport`](https://learn.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiadapter-checkinterfacesupport)
31	/// method.
32	#[must_use]
33	fn CheckInterfaceSupport(&self, interface_name: &GUID) -> HrResult<i64> {
34		let mut umd_ver = 0i64;
35		ok_to_hrresult(unsafe {
36			(vt::<IDXGIAdapterVT>(self).CheckInterfaceSupport)(
37				self.ptr(),
38				pcvoid(interface_name),
39				&mut umd_ver,
40			)
41		})
42		.map(|_| umd_ver)
43	}
44
45	/// [`IDXGIAdapter::EnumOutputs`](https://learn.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiadapter-enumoutputs)
46	/// method.
47	///
48	/// Returns an iterator over [`IDXGIOutput`](crate::IDXGIOutput) elements.
49	///
50	/// # Examples
51	///
52	/// ```no_run
53	/// use winsafe::{self as w, prelude::*};
54	///
55	/// let adapter: w::IDXGIAdapter; // initialized somewhere
56	/// # let adapter = unsafe { w::IDXGIAdapter::null() };
57	///
58	/// for output in adapter.EnumOutputs() {
59	///     let output = output?;
60	///     // ...
61	/// }
62	///
63	/// // Collecting into a Vec
64	/// let outputs: Vec<w::IDXGIOutput> =
65	///     adapter.EnumOutputs()
66	///         .collect::<w::HrResult<Vec<_>>>()?;
67	/// # w::HrResult::Ok(())
68	/// ```
69	#[must_use]
70	fn EnumOutputs(&self) -> impl Iterator<Item = HrResult<IDXGIOutput>> + '_ {
71		IdxgiadapterEnumoutputsIter::new(self)
72	}
73
74	/// [`IDXGIAdapter::GetDesc`](https://learn.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiadapter-getdesc)
75	/// method.
76	#[must_use]
77	fn GetDesc(&self) -> HrResult<DXGI_ADAPTER_DESC> {
78		let mut desc = DXGI_ADAPTER_DESC::default();
79		ok_to_hrresult(unsafe {
80			(vt::<IDXGIAdapterVT>(self).GetDesc)(self.ptr(), pvoid(&mut desc))
81		})
82		.map(|_| desc)
83	}
84}